package com.dm.manage.exception;

import com.dm.manage.common.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义业务异常类
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 状态码
     */
    private Integer code;
    
    /**
     * 错误信息
     */
    private String message;
    
    /**
     * 构造函数
     */
    public BusinessException(String message) {
        this.code = ResultCode.FAIL.getCode();
        this.message = message;
    }
    
    /**
     * 构造函数
     */
    public BusinessException(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }
    
    /**
     * 构造函数
     */
    public BusinessException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}